USE [NANS21V]
GO

/****** オブジェクト:  StoredProcedure [dbo].[TukaKiroku_smh]    スクリプト日付: 08/01/2018 09:27:27 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TukaKiroku_smh]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[TukaKiroku_smh]
GO

CREATE PROCEDURE [dbo].[TukaKiroku_smh]
	@TAIKAINO int,
	@KYOGINO int,
	@SUBNO int,
	@ROUNDNO int,
	@SUBSYUMOKUKUBUN int,
	@SUBKIROKUKUBUN int
AS
SELECT DISTINCT
	dbo.Kiroku(RO.TUKAKIROKU, @SUBSYUMOKUKUBUN, @SUBKIROKUKUBUN, 3) AS KIROKU,
	RO.TUKAKIROKU
FROM
	TBL_ROUND AS RO,
	TBL_RESULT AS RE
WHERE
	RO.TAIKAINO = RE.TAIKAINO
	AND RO.KYOGINO = RE.KYOGINO
	AND RO.SUBNO = RE.SUBNO
	AND RO.ROUNDNO = RE.ROUNDNO
	AND RO.TAIKAINO = @TAIKAINO
	AND RO.KYOGINO = @KYOGINO
	AND RO.SUBNO = @SUBNO
	AND RO.ROUNDNO = @ROUNDNO
